home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 09 - 1993 / 09.10 Oct 93 / Simpson's Rule / Simpson's Rule.p < prev    next >
Encoding:
Text File  |  1993-07-25  |  865 b   |  25 lines  |  [TEXT/PJMM]

  1. { © 1993  Marek Hajek. Hajek 's Solutions. Created 6-12-93 }
  2. {--This example illustrates Integral Computations }
  3.  
  4. {--------------------------Main Program----------------------------}
  5. PROGRAM Simpson;
  6.     USES
  7. (* Make sure you include the sane library *)
  8.         Auxiliary, Sane;
  9.  
  10.     CONST
  11.         kLowerLimit = -1;                  (* Corresponds to "a" *)
  12.         kUpperLimit = 1;                    (* Corresponds to "b" *)
  13.         kPartitions = 4;                 (* Corresponds to n = 100 *)
  14.  
  15.     VAR
  16.         result: Extended;                   (* The approximated result of the Integral *)
  17.  
  18. BEGIN
  19.     ShowText;
  20.  
  21.     result := ComputeIntegral(kLowerLimit, kUpperLimit, kPartitions, IntegrandFunction);
  22.     writeln('Integral with lower/upper limits ', kLowerLimit : 0, '/', kUpperLimit : 0, ', subintervals ', kPartitions : 0, ' is: ', result);
  23.  
  24.     readln; (* Stop here before the text window disappears *)
  25. END.